﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;

namespace FoNetParser
{
    internal class Templates
    {
        private static Assembly assembly = Assembly.GetAssembly(typeof(Templates));

        

        internal static XmlReader XhtmlToXslfo
        {
            get
            {
                return GetXmlDocument("xhtml-to-xslfo.xsl");
            }
        }

        internal static XmlReader XslFoToRtf
        {
            get
            {
                return GetXmlDocument("xslfo-to-rtf.xsl");
            }
        }

        internal static XmlReader XslFoToXhtml
        {
            get
            {
                return GetXmlDocument("xslfo-to-xhtml.xsl");
            }
        }

        

        internal static XmlReader GetXmlDocument(string name)
        {
            try
            {
                var stream = assembly.GetManifestResourceStream(string.Format("{0}{1}", "FoNetParser.Documents.", name));
                
                var settings = new XmlReaderSettings {DtdProcessing = DtdProcessing.Ignore};
                return XmlReader.Create(stream, settings);
            }
            catch (Exception ex)
            {
                throw new FileNotFoundException("Unable to find file in assemebly", name);
            }
        }
    }
}